home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vidlibp
/
vidpref.frm
< prev
next >
Wrap
Text File
|
1995-05-07
|
9KB
|
325 lines
VERSION 2.00
Begin Form VidPref
BorderStyle = 1 'Fixed Single
Caption = "Preferences"
ClientHeight = 2925
ClientLeft = 1095
ClientTop = 1485
ClientWidth = 4380
Height = 3330
HelpContextID = 310
Left = 1035
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2925
ScaleWidth = 4380
Top = 1140
Width = 4500
Begin CommandButton cmdSetOutput
Caption = "<"
Height = 240
HelpContextID = 310
Left = 1575
TabIndex = 13
Top = 2250
Width = 240
End
Begin PictureBox dlgFileOpen
Height = 480
Left = 3915
ScaleHeight = 450
ScaleWidth = 1170
TabIndex = 14
Top = 0
Width = 1200
End
Begin CommandButton cmdSetReport
Caption = "<"
Height = 240
HelpContextID = 310
Left = 1575
TabIndex = 12
Top = 1725
Width = 240
End
Begin CommandButton cmdFileChange
Caption = "..."
Height = 240
HelpContextID = 310
Left = 1395
TabIndex = 2
Top = 600
Width = 285
End
Begin CommandButton cmdCancel
Cancel = -1 'True
Caption = "&Cancel"
Height = 540
HelpContextID = 310
Left = 2835
TabIndex = 1
Top = 2175
Width = 1230
End
Begin CommandButton cmdOK
Caption = "&OK"
Default = -1 'True
Height = 540
HelpContextID = 310
Left = 2835
TabIndex = 0
Top = 1500
Width = 1230
End
Begin Label lblOutputName
BorderStyle = 1 'Fixed Single
Height = 225
Left = 180
TabIndex = 11
Top = 2250
Width = 1425
End
Begin Label lblReportName
BorderStyle = 1 'Fixed Single
Height = 240
Left = 180
TabIndex = 10
Top = 1725
Width = 1410
End
Begin Label lblPathName
BorderStyle = 1 'Fixed Single
Height = 225
Left = 180
TabIndex = 9
Top = 1125
Width = 3885
End
Begin Label lblFileName
BorderStyle = 1 'Fixed Single
Height = 225
Left = 180
TabIndex = 8
Top = 600
Width = 1230
End
Begin Label lblOutput
Caption = "Output:"
Height = 195
Left = 180
TabIndex = 7
Top = 2025
Width = 645
End
Begin Label lblReport
Caption = "Report:"
Height = 195
Left = 180
TabIndex = 6
Top = 1500
Width = 645
End
Begin Label lblPath
Caption = "Path:"
Height = 195
Left = 180
TabIndex = 5
Top = 900
Width = 465
End
Begin Label lblFile
Caption = "File:"
Height = 195
Left = 180
TabIndex = 4
Top = 375
Width = 375
End
Begin Label lblTitle
AutoSize = -1 'True
Caption = "Set Preference Defaults"
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 13.5
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 300
Left = 855
TabIndex = 3
Top = 75
Width = 2685
End
End
' Subsystem: Main
' Module: VidPref.Frm
' Date: 01/03/94
' Author: Richard Stauch
' Notes:
' This form allows the user to review and change the default
' file name, path, report and output for the Video Library
' program.
Option Explicit
DefInt A-Z
Sub cmdCancel_Click ()
' Remove the form from the display.
Unload VidPref
End Sub
Sub cmdFileChange_Click ()
' Select a path and file name to use.
Dim X As String ' Temp for fully qualified file name.
Dim Y As String ' Temp for simple file name.
dlgFileOpen.Filename = lblFileName.Caption
dlgFileOpen.InitDir = lblPathName.Caption
dlgFileOpen.Flags = OFN_CREATEPROMPT Or OFN_EXTENSIONDIFFERENT Or OFN_SHOWHELP
' If user presses the Cancel button.
On Error GoTo SelectError
' Display the common dialog box.
dlgFileOpen.Action = DLG_FILE_OPEN
' Clear the error handler.
On Error GoTo 0
' Retrieve the selected file path and name.
X$ = dlgFileOpen.Filename
Y$ = dlgFileOpen.Filetitle
If Len(Dir$(X$)) = 0 Then
' The file doesn't exist, so try to create it.
If CreateDataFile(X$) Then
' The file is created.
Else
' The file cannot be created.
Exit Sub
End If
End If
' The file exists, so indicate the new selection.
X$ = Left$(X$, Len(X$) - Len(Y$)) ' Remove the simple file name.
If Len(X$) > 3 Then
' The path includes subdirectories, so remove the trailing backslash.
X$ = Left$(X$, Len(X$) - 1)
End If
' Set the captions.
lblPathName.Caption = X$
lblFileName.Caption = Y$
Exit Sub
SelectError:
' Ignore Cancel button "error".
Resume Next
End Sub
Sub cmdOK_Click ()
' The user is done, so update the INI file.
Dim INIFile As Integer ' Define output file.
Dim I As Integer ' Temp count of chars in WinDir.
Dim WinDir As String ' Temp for the Windows directory.
Dim SaveDir As String ' Temp to save the current directory.
' Save the current directory to be restored later.
SaveDir$ = CurDir$
' Set defaults from label captions.
DefaultReport$ = lblReportName.Caption
DefaultOutput$ = lblOutputName.Caption
DefaultName$ = lblFileName.Caption
DefaultPath$ = lblPathName.Caption
' Set current session values based on these selections.
PathName$ = SetPathString(DefaultName$)
TempName$ = SetPathString("VidTmp.MDB")
CopyName$ = PathName$
' Retrieve the Windows directory.
WinDir$ = String(128, 0)
I% = GetWindowsDirectory(ByVal WinDir$, Len(WinDir$))
' Change to the Windows directory.
ChDir Left$(WinDir$, I%)
' If the file doesn't exist, create it.
INIFile% = FreeFile
Open "VidLib.INI" For Output As INIFile%
' Write the defaults, overwritting the original values.
Print #INIFile%, "[File]"
Print #INIFile%, "Path=" & DefaultPath$
Print #INIFile%, "Name=" & DefaultName$
Print #INIFile%, ""
Print #INIFile%, "[Print]"
Print #INIFile%, "Report=" & DefaultReport$
Print #INIFile%, "Output=" & DefaultOutput$
Close #INIFile%
' Restore the original directory.
ChDir SaveDir$
' Remove the window from the display.
Unload VidPref
End Sub
Sub cmdSetOutput_Click ()
' Set the report Output default.
If lblOutputName.Caption = "Window" Then
lblOutputName.Caption = "Printer"
ElseIf lblOutputName.Caption = "Printer" Then
lblOutputName.Caption = "File"
ElseIf lblOutputName.Caption = "File" Then
lblOutputName.Caption = "Window"
End If
End Sub
Sub cmdSetReport_Click ()
' Set the default Report.
If lblReportName.Caption = "Short" Then
lblReportName.Caption = "Long"
ElseIf lblReportName.Caption = "Long" Then
lblReportName.Capti